﻿using Engine;

namespace Game
{
    public class AreaInfo
    {
        public string Name;

        public Point2 PlainAreaMinCoord;

        public Point2 PlainAreaMaxCoord;

        public Point2 AreaCenterPoint;

        public float Radius;

        public Point3? OriginatePoint;

        public Point2 OriginateCoord;

        public int ChunkShiftCount;

        public int Long;

        public int Wide;

        public int HightShiftCount;

        public AreaInfo(string name, Point2 originateCoord, int hightShiftCount, Point3 originatePoint, int longnum, int widenum)
        {
            Name = name;
            Long = longnum;
            Wide = widenum;
            OriginatePoint = originatePoint;
            OriginateCoord = originateCoord;
            HightShiftCount = hightShiftCount;
            ChunkShiftCount = 1;
            int num = (int)MathUtils.Sqrt(Long * Long + Wide * Wide);
            PlainAreaMinCoord = OriginateCoord - new Point2(ChunkShiftCount);
            PlainAreaMaxCoord = OriginateCoord + new Point2(ChunkShiftCount) + new Point2(Long / 16, Long / 16);
            int num2 = (PlainAreaMaxCoord.X * 16 + PlainAreaMinCoord.X * 16 + 15) / 2;
            int num3 = (PlainAreaMaxCoord.Y * 16 + PlainAreaMinCoord.Y * 16 + 15) / 2;
            Radius = MathUtils.Min(num2 - PlainAreaMinCoord.X * 16, num3 - PlainAreaMinCoord.Y * 16);
            AreaCenterPoint = new Point2(originatePoint.X + Long / 2, originatePoint.Z + Wide / 2);
        }

        public bool CalculatPlainRange(Point2 coord)
        {
            if (coord.X >= PlainAreaMinCoord.X && coord.Y >= PlainAreaMinCoord.Y && coord.X <= PlainAreaMaxCoord.X && coord.Y <= PlainAreaMaxCoord.Y)
            {
                return true;
            }

            return false;
        }
    }
}